#include "PrecompiledHeader_Reborn.h"
#include "CelestialStar.h"

/*--------------------------------------------------------------------------*/

CelestialStar::CelestialStar(NodeCreation& nc) :
	ICelestial(nc, ECelestialType::Star)
{
	RenderTaskDesc desc;
	desc.m_material = g_Material->GetMaterial("mat_star");
	desc.m_argument = 10;
	desc.m_flags = ERenderTaskFlag::SortByDist;
	desc.m_priority = 0;
	desc.m_object = this;
	this->AddRenderTask(desc);

	desc.m_argument = 11;
	desc.m_flags = ERenderTaskFlag::LightSource;
	this->AddRenderTask(desc);

	desc.m_argument = 12;
	desc.m_flags = ERenderTaskFlag::UserInterface;
	this->AddRenderTask(desc);
	/*--------------------------------------------------------------------------*/

	this->SetOcclusionTestEnabled(false);
	this->GenerateContent();
}

/*--------------------------------------------------------------------------*/

CelestialStar::~CelestialStar()
{
	this->DestroyContent();
}

/*--------------------------------------------------------------------------*/

void CelestialStar::RenderableBinder(uint treeCalcFlags)
{
	this->BindRenderTasks(this->GetSceneInstance()->GetRenderPhase());
}

/*--------------------------------------------------------------------------*/

void CelestialStar::RenderableHelper(const uint i, ERenderQuality::Type quality, uint pendingInstances)
{
	switch (i)
	{
	case 10: // geometria
	{
		ROpenGL::BindVertexArray(ROpenGL::GetLargeSphereVao());
		ROpenGL::DrawVertexArray(0);

#ifdef VL_RENDER_STATISTICS
		g_Hud->GetStatisticsManager()->IncrementStatistic("CelestialStar");
#endif

		break;
	}

	case 11:
	{
		ROpenGL::BindVertexArray(ROpenGL::GetLargeSphereVao());
		ROpenGL::DrawVertexArray(0);

		break;
	}

	case 12:
	{
		if (g_Keyboard->GetKeyState(EKey::k_lalt))
		{
			g_Renderer->DrawLine3D(glm::vec3(-100.0f, 0.0f, 0.0f), glm::vec3(100.0f, 0.0f, 0.0f), NULL, Color::Red);
			g_Renderer->DrawLine3D(glm::vec3(0.0f, -100.0f, 0.0f), glm::vec3(0.0f, 100.0f, 0.0f), NULL, Color::Green);
			g_Renderer->DrawLine3D(glm::vec3(0.0f, 0.0f, -100.0f), glm::vec3(0.0f, 0.0f, 100.0f), NULL, Color::Blue);
		}

		break;
	}
	}
}

/*--------------------------------------------------------------------------*/

void CelestialStar::GenerateContent()
{

}

/*--------------------------------------------------------------------------*/

void CelestialStar::DestroyContent()
{

}

/*--------------------------------------------------------------------------*/
